<%@ page contentType="text/html;charset=UTF-8" %>
<%--<%@ include file="/WEB-INF/views/include/taglib.jsp"%>--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>流程管理</title>
    <meta name="decorator" content="default"/>
    <%--<script src="../../../static/lib/jquery.min.js"></script>--%>
    <script src="../static/lib/layui/layui.js" charset="utf-8"></script>
    <script src="../static/lib/x-layui.js"></script>
    <link rel="stylesheet" href="../static/lib/layui/css/layui.css" media="all">
    <link rel="stylesheet" type="text/css" href="../static/plugin/layer/skin/layer.css">
    <link rel="stylesheet" type="text/css" href="../static/css/dj-css.css">
    <link rel="stylesheet" type="text/css" href="../page/common/css/oa_system.css">
    <script type="text/javascript">
        //激活
        function confirmxactive(href){
            if (window.confirm('确定要激活吗？')) {
                window.location.href = href;
                return true;
            } else {
                return false;
            }
        }

        //挂起
        function confirmxsuspend(href) {
            if (window.confirm('确定要挂起吗？')) {
                window.location.href = href;
                return true;
            } else {
                return false;
            }
        }
        //删除
        function confirmxdeploymentId(href) {
            if (window.confirm('确定要删除流程吗？')) {
                window.location(href);
                return true;
            } else {
                return false;
            }
        }
        //转化
        function confirmxconverttoModel(href) {
            if (window.confirm('确定要转换为模型吗？')) {
//                window.location(href);
//                return true;
                $.ajax({
                    type: "post",
                    url: href,
                    dataType: "json",
                    success: function (data) {
                        console.log("数据为:"+data);
                        if(data.code==200){
                            alert(data.result.message);

//                            window.location.href="./page/activiti/model/model.html";
//                            window.location.href="./page/activiti/act/step.jsp";
                            window.location.href = "./actprocess/list.do?category=null&current=1&pagesize=5";
//

                        }else{
                            layer.msg("转型失败", {icon: 0});
                        }

                    }
                });
            } else {
                return false;
            }
        }
    </script>
    <script type="text/template" id="categoryBox">
        <%--<form id="categoryForm" action="../../actprocess/updateCategory.do" method="post" enctype="multipart/form-data"--%>
              <%--style="text-align:center;" class="form-search" onsubmit="loading('正在设置，请稍等...');"><br/>--%>
            <%--<input id="categoryBoxId" type="hidden" name="procDefId" value=""/>--%>
            <%--<select id="categoryBoxCategory" name="category">--%>
                <%--<option value="">无分类</option>--%>
                <%--<option value="1">分类1</option>--%>
                <%--<option value="2">分类2</option>--%>
                <%--&lt;%&ndash;<c:forEach items="${fns:getDictList('act_category')}" var="dict">&ndash;%&gt;--%>
                <%--&lt;%&ndash;<option value="${dict.value}">${dict.label}</option>&ndash;%&gt;--%>
                <%--&lt;%&ndash;</c:forEach>&ndash;%&gt;--%>
            <%--</select>--%>
            <%--<br/><br/>　　--%>
            <%--<input id="categorySubmit" class="btn btn-primary" type="submit" value="   保    存   "/>　　--%>
        <%--</form>--%>
    </script>

</head>
<body>

<h2>流程管理</h2>
<div class="main">
    <%--<ul class="nav nav-tabs">--%>
    <%--<li class="active"><a href="${rc.contextPath}/actprocess/list.do?category=null&current=1&pagesize=5">流程管理</a></li>--%>
    <%--<li><a href="${rc.contextPath}/actprocess/addprocess.do">部署流程</a></li>--%>
    <%--<li><a href="${rc.contextPath}/actprocess/runprocess.do">运行中的流程</a></li>--%>
    <%--</ul>--%>
    <form id="searchForm" action="${rc.contextPath}/actprocess/list.do" method="post" class="breadcrumb form-search clearfix">
        <%--<select id="category" name="category" class="input-medium fl">--%>
        <%--<option value="">全部分类</option>--%>
        <%--<c:forEach items="${categoryList}" var="c">--%>
        <%--<option value="${c.code}">${c.name}</option>--%>
        <%--</c:forEach>--%>
        <%--</select>--%>
            <input type="hidden" id="stepCategory" name="category" value="">
        <div class="dj-select dj-select-inline type fl">
            <label>请选择分类：</label>
            <div class="dj-select-content ">
                <div class="dj-select-input" flag='true'>
                    <span  readOnly class="dj-selected " type="text" name="" selectedCode=''
                           style="height:40px;line-height:40px;" id="leave_type">全部分类</span>
                    <i></i>
                </div>
                <ul class="dj-select-list">
                    <c:forEach items="${categoryList}" var="c">
                        <li code="${c.code}">${c.name}</li>
                    </c:forEach>
                </ul>
            </div>
        </div>


        <input id="btnSubmit" class="btn btn-primary search fl" type="submit" value="查询"/>
        <div class="layui-form-pane fl">
            <button type="button" class="createFlow"><a href="${rc.contextPath}/actprocess/addprocess.do">部署流程</a>
            </button>
        </div>
    </form>
    <%--<sys:message content="${message}"/>--%>

    <table class="" border="0" cellspacing="0" cellpadding="0">
        <thead>
        <tr>
            <th width="9%">流程分类</th>
            <th width="7%">流程ID</th>
            <th width="7%">流程标识</th>
            <th width="7%">流程名称</th>
            <th width="7%">流程版本</th>
            <th width="14%">部署时间</th>
            <th width="14%">流程XML</th>
            <th width="14%">流程图片</th>
            <th width="21%">操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${page.list}" var="object">
            <c:set var="process" value="${object[0]}"/>
            <c:set var="deployment" value="${object[1]}"/>
            <tr>
                <td>
                    <c:forEach items="${categoryList}" var="c">
                        <%--<c:choose>--%>
                            <%--<c:when test="${process.category eq c.code}">--%>
                                <%--${c.name}--%>
                            <%--</c:when>--%>
                            <%--<c:otherwise>--%>
                                <%--默认--%>
                                <%--&lt;%&ndash;${process.category}&ndash;%&gt;--%>
                            <%--</c:otherwise>--%>
                        <%--</c:choose>--%>
                        <%--<c:forEach items="${categoryList}" var="c" >--%>
                            <c:if test="${c.code eq process.category }">
                                ${c.name}
                            </c:if>
                        <%--</c:forEach>--%>
                    </c:forEach>
                </td>
                <td>${process.id}</td>
                <td>${process.key}</td>
                <td>${process.name}</td>
                <td><b title='流程版本号'>V: ${process.version}</b></td>
                <td><fmt:formatDate value="${deployment.deploymentTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                <td><a target="_blank"
                       href="${rc.contextPath}/actprocess/resourceread.do?procDefId=${process.id}&resType=xml">${process.resourceName}</a>
                </td>
                <td><a target="_blank"
                       href="${rc.contextPath}/actprocess/resourceread.do?procDefId=${process.id}&resType=image">${process.diagramResourceName}</a>
                </td>
                <td class="operate">
                    <c:if test="${process.suspended}">
                        <button class="show"><a href="${rc.contextPath}/actprocess/updatestate.do?state=active&procDefId=${process.id}"
                           onclick="return confirmxactive(this.href)">激活</a></button>
                    </c:if>
                    <c:if test="${!process.suspended}">
                    <button class="show"><a href="${rc.contextPath}/actprocess/updatestate.do?state=suspend&procDefId=${process.id}"
                           onclick="return confirmxsuspend(this.href)">挂起</a></button>
                    </c:if>
                    <button class="del">
                        <%--<a href='${rc.contextPath}/actprocess/delete.do?deploymentId=${process.deploymentId}'--%>
                       <%--onclick="return confirmxdeploymentId('确认要删除该流程吗？', this.href)">删除</a>--%>
                        <a href='${rc.contextPath}/actprocess/delete.do?deploymentId=${process.deploymentId}' onclick="return confirmxdeploymentId(this.href)">删除</a>
                    </button>
                    <button class="turnToModel">
                        <%--<a href='${rc.contextPath}/actprocess/converttoModel.do?procDefId=${process.id}'--%>
                       <%--onclick="return confirmxconverttoModel('确认要转换为模型吗？', this.href)">转换为模型</a>--%>
                            <a href='${rc.contextPath}/actprocess/converttoModel.do?procDefId=${process.id}' onclick="return confirmxconverttoModel(this.href)">转换为模型</a>
                    </button>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
    <div class="layui-form-item clearfix footer">
        <div class="fl rowsPerPage ">
            每页显示 <input type="number" value="5">条，共 <span>50</span>条
        </div>
        <div class="fl turnPage ">
            <span class="firstPage">首页</span>
            <span class="prePage">上一页</span>
            <span class="selectPage"><input type="text" value="1">/ <b>10</b> </span>
            <span class="nextPage">下一页</span>
            <span class="lastPage">末页</span>
            <span class="goPage">确认</span>
        </div>
    </div>


</div>

<script src="../static/lib/jquery.min.js"></script>
<script src="../static/lib/dj-js.js"></script>
</body>
</html>